﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace WindStyle.SPEntity.Attributes
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class LookupFieldAttribute : FieldAttribute
    {
        public string IdProperty { get; private set; }
        public string ValueProperty { get; private set; }
        public LookupValue ValuePart { get; private set; }

        public LookupFieldAttribute(string fieldName, string idProperty, string valueProperty)
            :base(fieldName)
        {
            this.Mode = MappingMode.ReadWrite;
            this.IdProperty = idProperty;
            this.ValueProperty = valueProperty;
            this.ValuePart = LookupValue.Id | LookupValue.Value;
        }
        

        public LookupFieldAttribute(string fieldName, LookupValue valuePart)
            : base(fieldName)
        {
            this.Mode = MappingMode.ReadOnly;
            this.ValuePart = valuePart;
        }
    }

    [Flags]
    public enum LookupValue
    {
        Id = 1,
        Value = 2
    }
}
